package com.jian.java;

import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.TypeHandler;

import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * @author Jiange
 * @create 2021-04-23-15:33
 */
public class MyTypeHandler implements TypeHandler<Object> {
    /**
     * 定义当前的数据如何保存到数据库内
     * @param preparedStatement
     * @param i
     * @param o
     * @param jdbcType
     * @throws SQLException
     */
    @Override
    public void setParameter(PreparedStatement preparedStatement, int i, Object o, JdbcType jdbcType) throws SQLException {
        //preparedStatement.setString(i,o.); i就是参数索引  第二个值为设置的值
    }

    @Override
    public Object getResult(ResultSet resultSet, String s) throws SQLException {
        //根据值返回枚举对象
        int anInt = resultSet.getInt(s);

        return null;
    }

    @Override
    public Object getResult(ResultSet resultSet, int i) throws SQLException {
        return null;
    }

    @Override
    public Object getResult(CallableStatement callableStatement, int i) throws SQLException {
        return null;
    }
}
